#!/bin/sh

BASE=${PWD}/${BASH_SOURCE[0]%/*}
LOG="${BASE}/../lists/to-release"

EX='0d1n apacket apt2 autonse autovpn bamf-framework bashscan blackbox-scanner
blackeye blue-hydra billcipher bof-detector boopsuite breads brut3k1t brutexss
cheetah-suite citadel cjexploiter cmsfuzz crackmapexec crozono cybercrowl
darkspiritz dagon d-tect dorkme entropy evilpdf expimp-lookup exploitpack
extracthosts facebash fbi filegps findmyiphone flamerobin ftpmap genisys
ghostdelivery gloom grabing graffiti hashpump hiddeneye hiddeneye-legacy
htrosbif honeycreds hubbit-sniffer hyde icloudbrutter infoga instashell
ircsnapshot koadic konan junkie jooforce jsearch l0l ld-shatner leroy-jenkins
levye liffy loot maigret maryam mdbtools mooscan mosca multitun mysql2sqlite
nbtscan neglected netcommander octopwnweb okadminfinder osinterator owasp-bywaf
paraxor-dwm paraxor-slock paraxor-st passcracking payloadmask peda pemcracker
pepe phonesploit phonia php-rfi-payload-decoder powerops pureblood pykek proctal
profuzz python2-ctags pwdlyser qrgen recentfilecache-parser recsech revipd
remot3d riwifshell routerhunter sb0x sea search1337 sees shitflood sigploit
simple-ducky skiptracer slurp slowloris-py smap smbexec smod smplshllctrlr
sniffer spiped spoofcheck sqlmap subbrute swamp sysdig takeover tempomail
token-hunter treasure tweetshell ultimate-facebook-scraper userrecon-py uppwn
userrecon valabind visql wascan webkiller weeman whatbreach winregfs wpseku
xss-freak yaaf yawast zeus-scanner'

rm -f $LOG

cd "${BASE}/../packages"

#pkgs=$(grep -r "^source=(.*['\"]git" * | cut -d '/' -f 1 | tr -s '\n' ' ' |
pkgs=$(grep -r "^source=(.*['\"::]git\+" * | cut -d '/' -f 1 | tr -s '\n' ' ' |
  sort -u)

for e in $EX
do
  pkgs=$(echo $pkgs | sed "s/\<$e\>//g")
done

for pkg in $pkgs
do
  echo "    > $pkg "
  cd "${BASE}/../packages/$pkg"
  makepkg -od > /dev/null 2>&1
  cd "${BASE}/../packages"
done

git add . 2> /dev/null
git commit -m 'vcs packages: version bumps' . 2> /dev/null
git push 2> /dev/null

lastcommit=$(git rev-parse --verify HEAD)
files=$(git diff-tree --no-commit-id --name-only -r $lastcommit |
  sed -E 's/packages\/|\/PKGBUILD//g')

echo
echo "last commit hash:"
echo $lastcommit
echo
echo "tools updated:"
echo $files | tr -s ' ' '\n' | tee -a $LOG

# EOF
